Multi-dimensional language style transfer

ABSTRACT

In some embodiments, a style transfer computing system receives, from a computing device, an input text and a request to transfer the input text to a target style combination including a set of target styles. The system applies a style transfer language model associated with the target style combination to the input text to generate a transferred text in the target style combination. The style transfer language model comprises a cascaded language model configured to generate the transferred text. The cascaded language model is trained using a set of discriminator models corresponding to the set of target styles. The system provides, to the computing device, the transferred text.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation application of U.S. application Ser.No. 17/073,258, filed Oct. 16, 2020, now allowed, which is incorporatedherein by reference in its entirety.

TECHNICAL FIELD

This disclosure relates generally to computer-implemented methods andsystems for natural language processing. Specifically, the presentdisclosure involves transferring a style of a sentence into amultidimensional style that contains multiple target styles.

BACKGROUND

Repurposing text content into different styles is an important part of acopywriter's job. Many scenarios require re-writing the same content indifferent tones of language (referred to as a style here) to suit theneeds of either end-users or the delivery channel. For example, aproduct launch announcement may be made in a casual style when sharedwith employees, but need to be in a more formal style when shared withthe board of directors or general users. Authoring methods can assisttransfer between such styles while trying to keep the underlying contentintact, without re-writing by the content creator or author.

However, existing authoring methods regenerate text on a single styledimension only (e.g., formality, sentiment, etc.). Text contents areoften myriad combinations of multiple related styles and personalizationof content thus requires optimizing across several styles. For example,changing excitement in a text can impact the formality of the text,which might be undesirable. As a result, the existing authoring toolsare unable to simultaneously transfer an input text into multiple styledimensions.

SUMMARY

Certain embodiments involve multidimensional language style transfer. Inone example, a system receives, from a computing device, an input textand a request to transfer the input text to a target style combinationincluding a set of target styles. The system applies a style transferlanguage model associated with the target style combination to the inputtext to generate a transferred text in the target style combination. Thestyle transfer language model comprises a cascaded language modelconfigured to generate the transferred text. The cascaded language modelis trained using a set of discriminator models corresponding to the setof target styles. The system provides, to the computing device, thetransferred text.

These illustrative embodiments are mentioned not to limit or define thedisclosure, but to provide examples to aid understanding thereof.Additional embodiments are discussed in the Detailed Description, andfurther description is provided there.

BRIEF DESCRIPTION OF THE DRAWINGS

Features, embodiments, and advantages of the present disclosure arebetter understood when the following Detailed Description is read withreference to the accompanying drawings.

FIG. 1 depicts an example of a computing environment for using a styletransfer language model to transfer a source sentence into a sentence ina multidimensional style containing multiple target styles, according tocertain aspects of the present disclosure.

FIG. 2 depicts an example of a process for generating and training styletransfer language models for different target multidimensional styles,according to certain aspects of the present disclosure.

FIG. 3 depicts an example of a block diagram illustrating therelationship between the various modules and models used for generatingthe style transfer language model, according to certain aspects of thepresent disclosure.

FIG. 4 depicts an example of a process for using a style transferlanguage model to transfer the style of a source sentence into asentence in a target multidimensional style, according to certainaspects of the present disclosure.

FIG. 5 depicts examples of source sentences and transferred sentencesusing the style transfer language models, according to certain aspectsof the present disclosure.

FIG. 6 depicts an example of a computing system that executes an imagemanipulation application for performing certain aspects of the presentdisclosure.

DETAILED DESCRIPTION

The present disclosure involves multidimensional language styletransfer. As discussed above, existing style transfer methods oftengenerate unsatisfactory results when transferring an input text to amultidimensional style or a style combination containing multiple targetstyles. Certain embodiments described herein address these limitationsby introducing language models trained for respective target styles asdiscriminator models in the style transfer language model. For instance,a model training subsystem generates and trains a discriminator modelfor each target style using a corresponding training dataset labeled forthe target style. The model training subsystem further generates amultidimensional style transfer language model (or “style transferlanguage model” in short) for a particular target style combination byincluding a cascaded language model and multiple discriminator models.These multiple discriminator models correspond to the multiple targetstyles contained in the particular target style combination. A styletransfer subsystem uses the trained style transfer language model totransfer a source sentence into a sentence in the particular targetstyle combination. For instance, for a source sentence “That person ishilarious” and a target style combination of “negative” sentiment and“informal,” the transferred sentence could be “That guy is so boring.”

The following non-limiting example is provided to introduce certainembodiments. In this example, a style transfer computing systemgenerates a pre-trained language model using a large unlabeled corpus oftext. The pre-trained language model is configured to accept a masked ornoisy input sentence as the input and output a complete sentence for thenoisy input. As a result, the pre-trained language model understands thegeneral language and can thus be utilized to initialize the models usedfor style transfer. The style transfer computing system furthergenerates a set of discriminator models for a set of styles containingtarget styles that may be included in a target style combination. Foreach style in the set of styles, the style transfer computing systemgenerates one discriminator model using a training dataset labeled forat least that style. According to certain aspects, the discriminatormodel for a style includes an encoder and a decoder each initializedusing the pre-trained language model and trained using the training setlabeled for the style. The trained discriminator is configured toconvert an input sentence to a sentence in the corresponding style.

To obtain a style transfer language model for a given target stylecombination containing multiple target styles, the style transfercomputing system constructs a cascaded language model including anencoder and a decoder. To speed up the training of the cascaded languagemodel, each of the encoder and the decoder is initialized with thepre-trained language model. The style transfer computing system furtherutilizes a corresponding discriminator model for each target stylecontained in the target style combination. As a result, the styletransfer language model includes the cascaded language model andmultiple discriminator models for the multiple target styles in thetarget style combination. The training of the style transfer languagemodel thus involves minimizing a loss function that includes a loss termfor the cascaded language model and multiple loss terms for the multiplediscriminator models. For a different target style combination, thestyle transfer computing system constructs a corresponding styletransfer language model in a similar way.

Utilizing the style transfer language model, the style transfercomputing system or another computing system, can convert an inputsource sentence to a sentence in the target style combination. Forexample, the style transfer computing system receives a request totransfer a source sentence into a target sentence in a target stylecombination. The style transfer computing system accesses a trainedstyle transfer language model corresponding to the target stylecombination. The style transfer computing system further applies thecascaded language model in the style transfer language model to thesource sentence to generate the output sentence in the target stylecombination.

As described herein, certain embodiments provide improvements inlanguage style transfer by using multiple discriminators in training astyle transfer language model to enable transferring the style of asentence into a target style combination. This allows the transfer of asentence to multiple styles to be performed simultaneously and withhigher accuracy. In addition, using multiple discriminators in thetraining eliminates the needs of using the training dataset labeled withall the target styles in the target style combination. Instead, separatetraining datasets independently labeled with respective target stylescan be used, thereby significantly reducing the time and complexity ofgenerating the training dataset and thus the overall training process.

As used herein, the term “style” or “text style” is used to refer to thetone of the text in terms of, for example, formality, sentiment, andexcitement. The type of the styles such as the formality, sentiment andexcitement is referred to as “style dimension.” A style can be a valuein a binary style dimension or a style dimension with multiple values.For example, in the formality style dimension, a style can be either“informal” or “formal.” In the sentiment style dimension, the style canbe “positive” or “negative.” In the excitement style dimension, thestyle can be one of “excited,” “neutral,” and “unexcited,” or othermultiple levels of excitement.

As used herein, the term “target multidimensional style” or “targetstyle combination” is used to refer to a combination of multiple targetstyles. For instance, a target multidimensional style or a target stylecombination can include a “formal” style in the formality styledimension and a “negative” sentiment style in the sentiment styledimension.

As used herein, the term “training dataset” is used to refer to adataset of sentences each labeled for at least one style. For example, atraining dataset may include a sentence “This is very helpful and Ireally appreciate it.” and a label of “positive” (for the sentimentstyle dimension) and a label of “formal” (for the formality styledimension). Similarly, the term “training dataset labeled for a styledimension” is used to refer to a dataset of sentences each of which hasa label for a style in that style dimension. For example, in a trainingdataset labeled for a formality style dimension, each sentence has atleast a label of “formal” style or “informal” style.

As used herein, the term “token” is used to refer to a word in a text,such as a sentence. The term “mask token” is used to refer to a token ora word used to mask a token in the text. For example, a mask token canbe denoted as “<mask>” and used to replace a word or token in a sentenceto mask that token or word.

Example Operating Environment for Multidimensional Style Transfer

Referring now to the drawings, FIG. 1 depicts an example of a computingenvironment 100 for building style transfer language model 116 and usingthe style transfer language model 116 to transfer a source sentence 108to a target sentence 124 in a target style combination 128. Thecomputing environment 100 includes a style transfer computing system102, which can include one or more processing devices that execute astyle transfer subsystem 104 to perform style transfer for inputsentences and a model training subsystem 106 for training the styletransfer language models 116 used in the style transfer. The computingenvironment 100 further includes a datastore 110 for storing data usedin the style transfer, such as the training datasets 112A-112C labeledfor different style dimensions (which may be referred to hereinindividually as a training dataset 112 or collectively as the trainingdatasets 112).

The style transfer subsystem 104 and the model training subsystem 106may be implemented using software (e.g., code, instructions, program)executed by one or more processing units (e.g., processors, cores),hardware, or combinations thereof. The software may be stored on anon-transitory storage medium (e.g., on a memory device). The computingenvironment 100 depicted in FIG. 1 is merely an example and is notintended to unduly limit the scope of claimed embodiments. One of theordinary skill in the art would recognize many possible variations,alternatives, and modifications. For example, in some implementations,the style transfer computing system 102 can be implemented using more orfewer systems or subsystems than those shown in FIG. 1 , may combine twoor more subsystems, or may have a different configuration or arrangementof the systems or subsystems.

The style transfer subsystem 104 is configured to receive a sourcesentence 108 in a source style. The source sentence 108 may be providedto the style transfer subsystem 104 by a user entering the sentence orby parsing the source sentence 108 from a document uploaded,transmitted, or otherwise provided to the style transfer computingsystem 102. The style transfer subsystem 104 is further configured toreceive a target style combination 128 that identifies a combination ofmultiple target styles to which the source sentence 108 is to betransferred.

To transfer the source sentence 108 into the target style combination128, the style transfer subsystem 104 employs a style transfer languagemodel 116. The style transfer computing system 102 generates the styletransfer language model 116 using the model training subsystem 106. Themodel training subsystem 106 builds and trains the style transferlanguage models 116 for different target style combinations 128. In FIG.1 , the model training subsystem 106 includes a pre-training module 138,a discriminator-generating module 134, and astyle-transfer-model-generating module 136.

The pre-training module 138 is configured to generate a pre-trainedlanguage model 118 on a large unlabeled corpus of text to understand thegeneral language. For example, the pre-training module 138 pre-trains aTransformer based language model with a masked language modeling (MLM)objective on the English encyclopedia text. This enables the languagemodel to predict masked words in the input sentences.

The discriminator-generating module 134 is configured to generate a setof discriminator models 114 for a set of single-dimensional styles. Morespecifically, the discriminator-generating module 134 constructs andtrains a discriminator model 114 for each style in the set of styles. Insome examples, the set of styles include the possible target styles thatmay be contained in a target style combination. For a given style in theset of styles, the discriminator-generating module 134 constructs adiscriminator model 114 by including an encoder and a decoder connectedto each other. To speed up the training of the discriminator model 114,each of the encoder and decoder is initialized as the pre-trainedlanguage model 118. The discriminator-generating module 134 furtherfine-tunes the discriminator model 114 using the training data for thisstyle.

In some examples, the training dataset 112 for a style dimensionincludes sentences that are labeled with a style in that styledimension. For instance, the training dataset for the formality styledimension includes the sentences that are either labelled with “formal”or “informal.” The training dataset 112 for a particular style dimensioncan thus be divided into multiple groups or subsets each correspondingto one style in this particular style dimension. Continuing the aboveexample, the training dataset for the formality style dimension can thusbe divided into two groups or subsets. The first group contains thetraining sentences each labelled with “formal” and the second groupcontains the training sentences each labelled with “informal.” Note thatthe sentences in each of the training datasets 112 may have labels forstyles in other style dimension. As such, the training datasets 112 fordifferent style dimensions may have overlapped sentences.

In order to train a discriminator model 114 for a certain style, thediscriminator-generating module 134 identifies the training dataset 112for the associated style dimension of the style and retrieves the groupor subset corresponding to the style. For instance, to train adiscriminator model 114 for a “formal” style, the discriminatorgenerating module 134 identifies that the training dataset 112 for theformality style dimension should be used. The discriminator generatingmodule 134 further retrieves the group or subset of the training dataset112 that are labelled as “formal.” The discriminator generating module134 further uses the retrieved subset of the training dataset to trainthe discriminator model 114 for the “formal” style. Thediscriminator-generating module 134 repeats the above process for eachstyle in the set of styles and thus generates a set of discriminatormodels 114 having the same number of styles in the set of styles.

The style-transfer-model-generating module 136 is configured to generatea style transfer language model 116 for each target style combination128 that the style transfer computing system 102 is configured totransfer a sentence to. In some examples, a style transfer languagemodel 116 includes a cascaded language model containing an encoder and adecoder connected to each other. The style-transfer-model-generatingmodule 136 initializes the encoder and the decoder using the pre-trainedlanguage model 118 and trains the cascaded language model for styletransfer. In order to enforce the style transfer to the target stylecombination 128, the style-transfer-model-generating module 136 furtherintroduces discriminator models 114 into the style transfer languagemodel 116. For each of the multiple target styles contained in thetarget style combination 128, the style-transfer-model-generating module136 adds a corresponding discriminator model 114 into the style transferlanguage model 116. The corresponding discriminator model 114 of a styleis the discriminator model 114 that is trained using the subset oftraining dataset 112 labeled for that style.

The style-transfer-model-generating module 136 trains the style transferlanguage model 116 by minimizing a loss function that includes a lossterm for the cascaded language model and multiple loss terms for themultiple discriminator models. The style-transfer-model-generatingmodule 136 repeats this process to construct and train style transferlanguage models 116 for different target style combinations 128.Additional details of generating the style transfer language model 116are provided below with respect to FIGS. 2 and 3 . In various examples,the pre-training module 138, the discriminator-generating module 134 orthe style-transfer-model-generating module 136 can be implemented as oneor more of program code, program code executed by processing hardware(e.g., a programmable logic array, a field-programmable gate array,etc.), firmware, or some combination thereof.

Among the generated style transfer language models 116, the styletransfer subsystem 104 identifies the style transfer language model 116for the received target style combination 128. The style transfersubsystem 104 further applies the style transfer language model 116 tothe source sentence 108 to generate the target sentence 124 in thetarget style combination 128. Additional details about generating thetarget sentence 124 in the target style combination 128 are providedbelow with respect to FIGS. 4 and 5 .

Examples of Computer-Implemented Operations for Multidimensional StyleTransfer

FIG. 2 depicts an example of a process for generating and training styletransfer language models for different target multidimensional styles ortarget style combinations, according to certain embodiments of thepresent disclosure. FIG. 2 is described in conjunction with FIG. 3 wherean example of a block diagram of the modules used for multidimensionalstyle transfer is depicted. One or more computing devices (e.g., thecomputing system 102 or the individual modules contained therein)implement operations depicted in FIG. 2 . For illustrative purposes, theprocess 200 is described with reference to certain examples depicted inthe figures. Other implementations, however, are possible.

At block 202, the process 200 involves generating a pre-trained languagemodel 118 for understanding the general language. In some examples, thepre-trained language model 118 is generated using a Transformer basedlanguage model and trained on a large unlabeled corpus of text. Theunlabeled corpus can be any corpus of text in a language for which thestyle transfer is to be performed. The corpus does not need labelsassociated with the sentences indicating their styles because at thisstage the pre-trained language model 118 is mainly utilized tounderstand the general language rather than the styles. For instance,the unlabeled corpus can include English text data extracted from one ormore websites or encyclopedia text. As shown in FIG. 3 , the unlabeledcorpus 302 can also be stored in the datastore 110 and the pre-trainingmodule 138 retrieves the unlabeled corpus 302 from the datastore 110 forgenerating the pre-trained language model 118.

In one example, the pre-training module 138 pre-trains the Transformerbased language model with a masked language modeling (MLM) objective.This enables the pre-trained language model 118 to predict masked wordsin the input sentence. In this example, the pre-training module 138randomly or pseudo-randomly samples a portion of the input tokens fromthe text stream of the corpus and replaces the sampled input words witha mask token, a random token, or the original token. In an example, thepre-training module 138 randomly or pseudo-randomly samples 15% of theinput tokens. For the 15% of the input tokens, the pre-training module138 replaces a token with a mask token 80% of the time, with a randomtoken 10% of the time, and keep it unchanged 10% of the time. Theobjective of the pre-trained language model 118 is to predict theoriginal identity of the masked or replaced word based on itsbidirectional context. The trained pre-trained language model 118 isthus able to predict masked words in the input sentence to generate acomplete sentence.

At block 204, the process 200 involves generating a discriminator model114 for each single-dimensional target style s_(i) ∈ S, where S denotesa set of N single-dimensional target styles. A target style combination128 thus contains multiple single-dimensional target styles from S. Insome examples, the discriminator-generating module 134 generates thediscriminator models 114 by fine-tuning the pre-trained language model118. For example, as shown in FIG. 3 , the discriminator-generatingmodule 134 generates a discriminator model 114 for a style s_(i) byincluding an encoder 316 and a decoder 318. To speed up the trainingprocess and to increase the accuracy of the discriminator model 114, thediscriminator generating module 134 uses the pre-trained language model118 generated by the pre-training module 138 to initialize the encoder316 and the decoder 318 of the discriminator model 114.

The discriminator generating module 134 further fine-tunes theencoder-decoder model with a causal language modeling (CLM) objective onthe subset of training dataset labelled for style s_(i), i=1, . . . , N,denoted as T_(i). The CLM training loss for the discriminator model 114for target style s_(i) with the corresponding training sub-dataset T_(i)is formulated as:

$\begin{matrix}{\mathcal{L}^{s_{i}} = {{\mathbb{E}}_{x \sim T_{i}}\lbrack {\sum\limits_{t = 1}^{n}{{- \log}{P_{LM}( { x_{t} \middle| x_{1} ,\ldots,x_{t - 1}} )}}} \rbrack}} & (1)\end{matrix}$

which is the loss over prediction probability of the next token x_(t) attime t, given the previous tokens x₁, . . . , x_(t−1) from the sentence.Here, n the total number of tokens in the sentence. This training steptransforms the language distribution of the discriminator model 114 to asingle style s_(i). FIG. 3 illustrates the discriminator models114A-114C generated by the discriminator-generating module 134. In somecases, one or more operations described with respect to block 204 can beused to implement a step for generating a discriminator model 114 foreach of the target styles based on the training datasets 112.

At block 206, the process 200 involves obtaining a target stylecombination 128, such as accessing the next target style combination 128from a list of target style combinations 128 that the style transfercomputing system 102 is configured to handle. Given the target stylecombination 128, at block 208, the style-transfer-model-generatingmodule 136 constructs and trains a style transfer language model 116 forthis particular target style combination 128. As shown in FIG. 3 , theconstructed style transfer language model 116 includes a cascadedlanguage model 304 by cascading an encoder 308 with a decoder 306. Insome examples, the encoder 308 and the decoder 306 are each initializedas the pre-trained language model 118 generated by the pre-trainingmodule 138.

If the pre-trained language model 118 is generated using the Transformerbased language model, the encoder 308 and the decoder 306 can beconnected by randomly or pseudo-randomly initialized attention layers.The architecture of Transformer based language models allows cascadingtwo instances of the pre-trained language model 118, without explicitlyaligning the encoder's output and decoder's input, by implicitlyemploying the in-built attention mechanism in the Transformerarchitecture. This can be achieved by initializing the encoder 308 andthe decoder 306 with learned parameters of the pre-trained languagemodel 118.

To instill style aware transfer ability to the cascaded language model304, the style-transfer-model-generating module 136 fine-tunes thecascaded encoder and decoder with a denoising autoencoder (DAE) lossusing a training dataset T for the cascaded language model 304. For theparticular target style combination 128 for which the cascaded languagemodel 304 is built, the training dataset T includes a combination of thesubsets of the training datasets 112 for the target styles contained inthe target style combination 128. These subsets of training datasets 112are used to independently train the respective discriminator models 114as described above with respect to block 204. For example, as shown inFIG. 3 , if the target style combination 128 includes target styles Band C, the training dataset T for the cascaded language model 304includes the subset of training dataset for style B and the subset oftraining dataset for style C.

In other examples, the training dataset for the cascaded language model304 includes a randomized mixture of the subsets of training datasets112 for the styles contained in the target style combination 128. Theorder of the training sentences in these subsets of training datasets112 are randomized and this randomized sequence of training sentencesare provided to the cascaded language model 304 for training.

Under the DAE objective, the encoder 308 takes as input noisy maskedversion of the original sentence x and tries to fill in the mask tokenas per the MLM objective that it was pre-trained on. The decoder 306attempts to re-create the stylistic version of the original sentencefrom this noisy output of the encoder. 308 The overall trainingobjective of the cascaded language model 304 can be formulated as:

_(DAE)(θ)=

_(x˜T)[−log P _(θ)(x|{tilde over (x)})]  (2)

Here, θ are the trainable parameters of the joint encoder-decoder modelof the cascaded language model 304. The noisy version {tilde over (x)}of sentence x from the training dataset T is obtained after randomly orpseudo-randomly dropping tokens from x with probability p_(drop) andrandomly or pseudo-randomly masking the tokens in x with a probabilityof p_(mask). In conjunction, the encoder 308 and decoder 306 learn toreconstruct the input sentence x by filling in appropriate wordsaccording to the target style combination 128. Note that the cascadedlanguage model 304 does not use the source style of the input sentence xand is trained to generate sentences to match the styles of the trainingdataset T.

To further increase the accuracy of the style transfer of the cascadedlanguage model 304, the style-transfer-model-generating module 136includes discriminator models in the style transfer language model 116to take the output of the cascaded language model 304 as input andprovide feedback to the cascaded language model 304 for differentiatingbetween the target style dimensions. Compared with a classifier-baseddiscriminator, a language model based discriminator takes into accountthe language distribution of the target style. In addition, the languagemodel based discriminators use only the target style training datasetsfor training the transfer model, whereas the classifier would requireboth source and target style corpus to distinguish between a sentence asbeing from one style or another. In some examples, thestyle-transfer-model-generating module 136 uses the discriminator models114 generated and trained by the discriminator generating module 134based on the pre-trained language model 118. The discriminator models114 to be included in the style transfer language model 116 depend onthe styles in the target style combination 128. In the example FIG. 3 ,the target style combination 128 includes styles B and C, and thus thediscriminator models 114 included in the style transfer language model116 contain the discriminator model 114 for style B and thediscriminator models 114 for style C.

For a target style combination 128 containing k target styles, s={s₁,s₂, . . . , s_(k)}, training of its corresponding style transferlanguage model 116 is thus performed by minimizing an overall lossfunction defined over the cascaded language model 304 and thediscriminator models 114. If the cascaded language model 304 isfine-tuned using the DAE loss and the discriminator models 114 arefine-tuned using the CLM loss, the overall loss function of the styletransfer language model 116 becomes:

$\begin{matrix}{\mathcal{L} = {{\lambda_{DAE}{{\mathbb{E}}_{x \sim T}\lbrack {{- \log}{P_{\theta}( x \middle| \overset{˜}{x} )}} \rbrack}} + {\sum\limits_{i = 1}^{k}{\lambda_{i}{{\mathbb{E}}_{{x \sim T},{x^{\prime} \sim {P_{\theta}(x)}}}\lbrack {\sum\limits_{t = 1}^{n_{x}}{{- \log}{P_{LM_{i}}( { x_{t}^{\prime} \middle| x_{1}^{\prime} ,\ldots,x_{t - 1}^{\prime}} )}}} \rbrack}}}}} & (3)\end{matrix}$

where λ_(DAE) and {λ_(i)}₁₌₁ ^(k) are hyper-parameters. λ_(DAE) is theweight coefficient of the DAE loss

_(x˜T)[−log P_(θ)(x|{tilde over (x)})], and λ_(i) is the weightcoefficient for discriminator loss

_(x˜T,x′˜P) _(θ) _((x))[Σ_(t=1) ^(n) ^(x) −log P_(LM) _(i) (x′_(t)|x′₁,. . . x′_(t−1))] corresponding to style s_(i), where n_(x) is the numberof tokens in the sentence x, and x′ is the transferred version ofsentence x generated by the cascaded language model 304. The overallloss is the weighted sum of the DAE loss and the discriminative losses.The DAE loss attempts to reconstruct the input from its noisy versionbecause the input x is from one of the target styles. At the same time,the discriminative losses attempt to ensure that the transferred outputis aligned with the other styles as well for which x has no information.In conjunction, these losses lead the transfer towards the target stylecombination s={s₁, s₂, . . . , s_(k)}.

From the above, it can be seen that the loss term is calculated for thetransferred sentence x′ using the discriminator model 114 for eachtarget style. In this way, the adversarial training for thediscriminator can be eliminated, since the fine-tuned discriminatormodel 114 is implicitly capable of assigning high values to negativesamples (out-of-style samples).

Although the above describes the random masking for generating noisysentence input to the cascaded language model 304, in additionalexamples, attribute masking is employed. In attribute masking, insteadof randomly choosing words for masking, attribute-specific (orstyle-specific) words are identified from the input sentence andreplaced with a [MASK] token. To identify these attribute (orstyle-specific) words, input tokens with high salience (e.g., relativefrequency) in a source corpus containing the input text are tagged asattribute markers. The intuition behind this is that the words that aremore frequent in the source style corpus than the target style corpusreflect the style specific information. Although the rest of thetraining process makes use of the target corpus alone, identifying theattribute-specific words makes use of the source corpus as well forcomparing the relative frequency of each token. For a target stylecombination, the attribute words are identified from the mixture ofsubsets of training datasets from each of the target styles and theirrespective source styles. With such masking, the model understands andlearns the nuances of attribute vocabulary faster and perform the styletransfer better.

In some cases, one or more operations described with respect to block208 can be used to implement a step for training, based on the set oftraining dataset 112 and the discriminator models for the set of targetstyles, a style transfer language model 116 for a target stylecombination that comprises two or more target styles.

At block 210, the process 200 involves determining whether there aremore target style combinations. If so, the process 200 involvesaccessing the next target style combination at block 206 andconstructing and training a style transfer language model 116 for such atarget style combination 128 at block 208. If there are no more targetstyle combinations for model construction, the process 200 involvesoutputting the style transfer language models 116 at block 212.

The operations described above with respect to FIG. 2 and the models andmodules shown in FIG. 3 are for illustration purposes only and shouldnot be construed as limiting. Fewer or more blocks can be included inthe process 200 of FIG. 2 . Likewise, fewer or more modules or modelscan be included in the block diagram shown in FIG. 3 . For example, thediscriminator models 114 and the cascaded language model 304 can bebuilt and trained without using the pre-trained language model 118. Assuch, block 202 for generating the pre-trained language model 118 can beeliminated from FIG. 2 , and the pre-training module 138 and thepre-trained language model 118 can be removed from FIG. 3 . Otherblocks, modules or models can be added or removed from FIGS. 2 and 3depending on the way the style transfer language model 116 isconstructed.

FIG. 4 depicts an example of a process 400 for using a style transferlanguage model 116 to transfer a source sentence 108 to a targetsentence 124 in a target style combination 128, according to certainembodiments of the present disclosure. It should be noted that in theexample of the process 400 shown in FIG. 4 , the model style transferlanguage model 116 used for style transfer has already been trained asdiscussed above with respect to FIGS. 2 and 3 . One or more computingdevices (e.g., the style transfer computing system 102) implementoperations depicted in FIG. 4 by executing suitable components (e.g.,the style transfer subsystem 104). For illustrative purposes, theprocess 400 is described with reference to certain examples depicted inthe figures. Other implementations, however, are possible.

At block 402, the process 400 involves the style transfer subsystem 104receiving a source sentence 108 and a target style combination 128. Thetarget style combination 128 specifies two or more target styles thatthe source sentence 108 is to be transferred into. At block 404, theprocess 400 involves the style transfer subsystem 104 accessing thestyle transfer language model 116 that is designed for the target stylecombination 128 and applying the style transfer language model 116 tothe source sentence 108. The style transfer subsystem 104 retrieves thestyle transfer language model 116, for example, from a datastoreconfigured for storing the available style transfer language models 116.The style transfer subsystem 104 provides the source sentence 108 as aninput to the style transfer language model 116 and obtains the output ofthe style transfer language model 116 as the target sentence 124. Inexamples, the cascaded language model 304 of the style transfer languagemodel 116 is used to generate the target sentence 124 without using thediscriminator models 114. In other words, the discriminator models 114that are used for training the cascaded language model 304 are no longerused when generating the target sentence 124. At block 406, the styletransfer subsystem 104 outputs the target sentence 124, for example, bydisplaying the target sentence 124 on a display device, writing thetarget sentence 124 to a file in a storage device, or sending the targetsentence 124 to a remote computing device over a network.

FIG. 5 depicts examples of source sentences and transferred sentencesusing the style transfer language model 116, according to certainaspects of the present disclosure. In the example shown in FIG. 5 , fourtarget style combinations 128 are shown: positive and formal, negativeand formal, positive and informal, negative and informal. FIG. 5 alsoshows the transferred sentences generated by a prior art using atwo-stage style transfer approach by transferring a sentence to a firststyle and then to a second style.

The results shown in FIG. 5 are generated with the following settings.For the pre-trained language model 118, a 12-layer Transformer modelwith 512 hidden units, 16 heads, a dropout rate of 0.1 are used. Themodels are trained with the Adam optimizer, and a learning rate of 10⁻⁴.To speed up the training process, the pre-trained language model 118 isseparately fine-tuned before initializing the encoder-decoder setup inthe discriminator models 114 and the cascaded language model 304. Foreach of the discriminator models 114, thediscriminator-generating-module 134 or another module in the modeltraining subsystem 106 uses the subset of training dataset for the stylecorresponding to the discriminator model to fine-tune the pre-trainedlanguage model with the causal language modeling (CLM) objective. Thisfine-tuned pre-trained language model is used to initialize the decoderof the corresponding discriminator model 114. The encoder of thediscriminator model 114 is still initialized using the pre-trainedlanguage model 118. The discriminator-generating module 134 then trainsthe encoder-decoder framework of the discriminator model 114 asdiscussed above (e.g., the discussion with regard to block 204 of FIG. 2).

Similarly, for the cascaded language model 304, before starting thetraining of the encoder-decoder framework of the cascaded language model304, the style-transfer-model-generating module 136, or another modulein the model training subsystem 106, uses the subsets of trainingdatasets for the styles in the target style combination to fine-tune thepre-trained language model 118. This fine-tuning process uses acombination of CLM loss and discriminator loss to handle partiallyannotated dataset for the target style combination as follows:

$\begin{matrix}{\mathcal{L} = {{\lambda_{CLM}{{\mathbb{E}}_{x \sim T}\lbrack {\sum_{t = 1}^{n}{- {\log{P_{LM}( { x_{t} \middle| x_{1} ,\ldots,x_{t - 1}} )}}}} \rbrack}} + {\sum\limits_{i = 1}^{k}{\lambda_{i}{{\mathbb{E}}_{{x \sim T},{x^{\prime} \sim {P_{\theta}(x)}}}\lbrack {\sum\limits_{t = 1}^{n_{x}}{{- \log}{P_{LM_{i}}( { x_{t}^{\prime} \middle| x_{1}^{\prime} ,\ldots,x_{t - 1}^{\prime}} )}}} \rbrack}}}}} & (4)\end{matrix}$

where, λ_(CLM) is the weight coefficient of the CLM loss and otherparameters are similar to those in Eqn. (3). This fine-tuned model isused to initialize the encoder of the cascaded language model 304. Theencoder of the cascaded language model 304 is still initialized usingthe pre-trained language model 118. The style-transfer-model-generatingmodule 136 then trains the encoder-decoder framework of the cascadedlanguage model 304 as discussed above (e.g., the discussion with regardto block 208 of FIG. 2 ).

As shown in FIG. 5 , the prior art model does not perform as well on thecontent preservation as the style transfer language model 116 disclosedherein. This is because transferring style one after another leads tolarge content loss. In contrast, the style transfer language model 116presented here maintains good content preservation and conforms well tothe target style combination.

Although the above description focuses on English language styletransfer, the multidimensional style transfer presented herein appliesto any language as long as the training datasets and text corpus are inthe proper language. Further, while a sentence is described above as theinput to the style transfer language model 116, two or more sentencescan be used as the input to the style transfer language model 116 forstyle transfer. As a result, the target sentence 124 may also containtwo or more sentences.

Computing System Example for Implementing Multidimensional StyleTransfer

Any suitable computing system or group of computing systems can be usedfor performing the operations described herein. For example, FIG. 6depicts an example of a computing system 600 that can implement thecomputing environment of FIG. 1 . In some embodiments, the computingsystem 600 includes a processing device 602 that executes the styletransfer subsystem 104, a model training subsystem 106, or a combinationof both, a memory that stores various data computed or used by the styletransfer subsystem 104 or the model training subsystem 106, an inputdevice 614 (e.g., a mouse, a stylus, a touchpad, a touchscreen, etc.),and a display device 612 that displays content generated by the styletransfer subsystem 104. For illustrative purposes, FIG. 6 depicts asingle computing system on which the style transfer subsystem 104 or themodel training subsystem 106 is executed, and the input device 614 anddisplay device 612 are present. But these applications, datasets, anddevices can be stored or included across different computing systemshaving devices similar to the devices depicted in FIG. 6 .

The depicted example of a computing system 600 includes a processingdevice 602 communicatively coupled to one or more memory devices 604.The processing device 602 executes computer-executable program codestored in a memory device 604, accesses information stored in the memorydevice 604, or both. Examples of the processing device 602 include amicroprocessor, an application-specific integrated circuit (“ASIC”), afield-programmable gate array (“FPGA”), or any other suitable processingdevice. The processing device 602 can include any number of processingdevices, including a single processing device.

The memory device 604 includes any suitable non-transitorycomputer-readable medium for storing data, program code, or both. Acomputer-readable medium can include any electronic, optical, magnetic,or other storage device capable of providing a processor withcomputer-readable instructions or other program code. Non-limitingexamples of a computer-readable medium include a magnetic disk, a memorychip, a ROM, a RAM, an ASIC, optical storage, magnetic tape or othermagnetic storage, or any other medium from which a processing device canread instructions. The instructions may include processor-specificinstructions generated by a compiler or an interpreter from code writtenin any suitable computer-programming language, including, for example,C, C++, C#, Visual Basic, Java, Python, Perl, JavaScript, andActionScript.

The computing system 600 may also include a number of external orinternal devices, such as an input device 614, a display device 612, orother input or output devices.

For example, the computing system 600 is shown with one or moreinput/output (“I/O”) interfaces 608. An I/O interface 608 can receiveinput from input devices or provide output to output devices. One ormore buses 606 are also included in the computing system 600. The buses606 communicatively couples one or more components of a respective oneof the computing system 600.

The computing system 600 executes program code that configures theprocessing device 602 to perform one or more of the operations describedherein. The program code includes, for example, the style transfersubsystem 104, the model training subsystem 106 or other suitableapplications that perform one or more operations described herein. Theprogram code may be resident in the memory device 604 or any suitablecomputer-readable medium and may be executed by the processing device602 or any other suitable processor. In some embodiments, all modules inthe model training subsystem 106 (e.g., thestyle-transfer-model-generating module 136, the discriminator generatingmodule 134, the pre-training module 138, etc.) are stored in the memorydevice 604, as depicted in FIG. 6 . In additional or alternativeembodiments, one or more of these modules from the model trainingsubsystem 106 are stored in different memory devices of differentcomputing systems.

In some embodiments, the computing system 600 also includes a networkinterface device 610. The network interface device 610 includes anydevice or group of devices suitable for establishing a wired or wirelessdata connection to one or more data networks. Non-limiting examples ofthe network interface device 610 include an Ethernet network adapter, amodem, and/or the like. The computing system 600 is able to communicatewith one or more other computing devices (e.g., a computing device thatreceives inputs for the style transfer subsystem 104 or displays outputsof the style transfer subsystem 104) via a data network using thenetwork interface device 610.

An input device 614 can include any device or group of devices suitablefor receiving visual, auditory, or other suitable input that controls oraffects the operations of the processing device 602. Non-limitingexamples of the input device 614 include a touchscreen, stylus, a mouse,a keyboard, a microphone, a separate mobile computing device, etc. Adisplay device 612 can include any device or group of devices suitablefor providing visual, auditory, or other suitable sensory output.Non-limiting examples of the display device 612 include a touchscreen, amonitor, a separate mobile computing device, etc.

Although FIG. 6 depicts the input device 614 and the display device 612as being local to the computing device that executes the style transfersubsystem 104, other implementations are possible. For instance, in someembodiments, one or more of the input device 614 and the display device612 can include a remote client-computing device that communicates withthe computing system 600 via the network interface device 610 using oneor more data networks described herein.

General Considerations

Numerous specific details are set forth herein to provide a thoroughunderstanding of the claimed subject matter. However, those skilled inthe art will understand that the claimed subject matter may be practicedwithout these specific details. In other instances, methods,apparatuses, or systems that would be known by one of ordinary skillhave not been described in detail so as not to obscure claimed subjectmatter.

Unless specifically stated otherwise, it is appreciated that throughoutthis specification discussions utilizing terms such as “processing,”“computing,” “calculating,” “determining,” and “identifying” or the likerefer to actions or processes of a computing device, such as one or morecomputers or a similar electronic computing device or devices, thatmanipulate or transform data represented as physical electronic ormagnetic quantities within memories, registers, or other informationstorage devices, transmission devices, or display devices of thecomputing platform.

The system or systems discussed herein are not limited to any particularhardware architecture or configuration. A computing device can includeany suitable arrangement of components that provide a result conditionedon one or more inputs. Suitable computing devices include multi-purposemicroprocessor-based computer systems accessing stored software thatprograms or configures the computing system from a general purposecomputing apparatus to a specialized computing apparatus implementingone or more embodiments of the present subject matter. Any suitableprogramming, scripting, or other types of language or combinations oflanguages may be used to implement the teachings contained herein insoftware to be used in programming or configuring a computing device.

Embodiments of the methods disclosed herein may be performed in theoperation of such computing devices. The order of the blocks presentedin the examples above can be varied—for example, blocks can bere-ordered, combined, and/or broken into sub-blocks. Certain blocks orprocesses can be performed in parallel.

The use of “adapted to” or “configured to” herein is meant as open andinclusive language that does not foreclose devices adapted to orconfigured to perform additional tasks or steps. Additionally, the useof “based on” is meant to be open and inclusive, in that a process,step, calculation, or other action “based on” one or more recitedconditions or values may, in practice, be based on additional conditionsor values beyond those recited. Headings, lists, and numbering includedherein are for ease of explanation only and are not meant to belimiting.

While the present subject matter has been described in detail withrespect to specific embodiments thereof, it will be appreciated thatthose skilled in the art, upon attaining an understanding of theforegoing, may readily produce alterations to, variations of, andequivalents to such embodiments. Accordingly, it should be understoodthat the present disclosure has been presented for purposes of examplerather than limitation, and does not preclude the inclusion of suchmodifications, variations, and/or additions to the present subjectmatter as would be readily apparent to one of ordinary skill in the art.

1. A method performed by one or more computing devices, comprising:receiving, from a computing device, an input text and a request totransfer the input text to a target style combination including a set oftarget styles; applying a style transfer language model associated withthe target style combination to the input text to generate a transferredtext in the target style combination, wherein the style transferlanguage model comprises a cascaded language model configured togenerate the transferred text, and wherein the cascaded language modelis trained using a set of discriminator models corresponding to the setof target styles; and providing, to the computing device, thetransferred text.
 2. The method of claim 1, wherein the cascadedlanguage model includes an encoder and a decoder, each of the encoderand the decoder initialized using a pre-trained language model.
 3. Themethod of claim 1, wherein the input text includes an input sentence andwherein the transferred text includes a transferred input sentence. 4.The method of claim 1, wherein the computing device displays thetransferred text.
 5. The method of claim 1, further comprising trainingthe cascaded language model, wherein training the cascaded languagemodel comprises: generating the set of discriminator modelscorresponding to a set of styles based on a set of training datasets;and generating the style transfer language model comprising the cascadedlanguage model and the set of discriminator models; and training thestyle transfer language model based on the set of training datasets. 6.The method of claim 5, wherein training the cascaded language modelfurther comprises generating a pre-trained language model, wherein theset of discriminator models corresponding to the set of styles aregenerated based on the pre-trained language model, and the cascadedlanguage model is generated based on the pre-trained language model. 7.The method of claim 1, wherein each discriminator model in the set ofdiscriminator models corresponds to a style in the set of styles, andwherein generating the set of discriminator models comprising trainingeach discriminator model using a corresponding subset of trainingdataset in the set of training datasets that is labeled for at least thestyle.
 8. The method of claim 4, wherein each discriminator model in theset of discriminator models includes an encoder and a decoder, whereineach respective encoder and each respective decoder is initialized usingthe pre-trained language model and is fine-tuned through training usingthe corresponding subset of training dataset.
 9. A non-transitorycomputer-readable medium having program code that is stored thereon, theprogram code executable by one or more processing devices for performingoperations comprising: receiving, from a computing device, an input textand a request to transfer the input text to a target style combinationincluding a set of target styles; applying a style transfer languagemodel associated with the target style combination to the input text togenerate a transferred text in the target style combination, wherein thestyle transfer language model comprises a cascaded language modelconfigured to generate the transferred text, and wherein the cascadedlanguage model is trained using a set of discriminator modelscorresponding to the set of target styles; and providing, to thecomputing device, the transferred text.
 10. The non-transitorycomputer-readable medium of claim 9, wherein the cascaded language modelincludes an encoder and a decoder, each of the encoder and the decoderinitialized using a pre-trained language model.
 11. The non-transitorycomputer-readable medium of claim 9, wherein the input text includes aninput sentence and wherein the transferred text includes a transferredinput sentence.
 12. The non-transitory computer-readable medium of claim9, wherein the computing device displays the transferred text.
 13. Thenon-transitory computer-readable medium of claim 9, the operationsfurther comprising training the cascaded language model, whereintraining the cascaded language model comprises: generating the set ofdiscriminator models corresponding to a set of styles based on a set oftraining datasets; and generating the style transfer language modelcomprising the cascaded language model and the set of discriminatormodels; and training the style transfer language model based on the setof training datasets.
 14. The non-transitory computer-readable medium ofclaim 13, wherein training the cascaded language model further comprisesgenerating a pre-trained language model, wherein the set ofdiscriminator models corresponding to the set of styles are generatedbased on the pre-trained language model, and the cascaded language modelis generated based on the pre-trained language model.
 15. Thenon-transitory computer-readable medium of claim 9, wherein eachdiscriminator model in the set of discriminator models corresponds to astyle in the set of styles, and wherein generating the set ofdiscriminator models comprising training each discriminator model usinga corresponding subset of training dataset in the set of trainingdatasets that is labeled for at least the style.
 16. The non-transitorycomputer-readable medium of claim 9, wherein each discriminator model inthe set of discriminator models includes an encoder and a decoder,wherein each respective encoder and each respective decoder isinitialized using the pre-trained language model and is fine-tunedthrough training using the corresponding subset of training dataset. 17.A system, comprising: a processor; and a non-transitorycomputer-readable medium having program code that is stored thereonthat, when executed by the processor, cause the system to performoperations comprising: receiving, from a computing device, an input textand a request to transfer the input text to a target style combinationincluding a set of target styles; applying a style transfer languagemodel associated with the target style combination to the input text togenerate a transferred text in the target style combination, wherein thestyle transfer language model comprises a cascaded language modelconfigured to generate the transferred text, and wherein the cascadedlanguage model is trained using a set of discriminator modelscorresponding to the set of target styles; and providing, to thecomputing device, the transferred text.
 18. The system of claim 17,wherein the input text includes an input sentence and wherein thetransferred text includes a transferred input sentence.
 19. The systemof claim 17, the operations further comprising training the cascadedlanguage model, wherein training the cascaded language model comprises:generating the set of discriminator models corresponding to a set ofstyles based on a set of training datasets; and generating the styletransfer language model comprising the cascaded language model and theset of discriminator models; and training the style transfer languagemodel based on the set of training datasets.
 20. The system of claim 19,wherein training the cascaded language model further comprisesgenerating a pre-trained language model, wherein the set ofdiscriminator models corresponding to the set of styles are generatedbased on the pre-trained language model, and the cascaded language modelis generated based on the pre-trained language model.